#include <iostream>
#include "student.h"
using namespace std;

Student::Student(long int id, string name) : id(id), name(name){};

void Student::setScore(float chinese_score, float maths_score, float english_score)
{
    if (chinese_score != 0)
    {
        Chinese_score = chinese_score;
    }
    if (maths_score != 0)
    {
        Maths_score = maths_score;
    }
    if (english_score != 0)
    {
        English_score = english_score;
    }
}

void Student::render()
{
    average = (Chinese_score + Maths_score + English_score) / 3;
    std::cout << id << "\t" << name << "\t" << Chinese_score << "\t" << Maths_score << "\t" << English_score << "\t" << average << std::endl;
}

int main()
{
    int num;
    long int id;
    float chinese_score, maths_score, english_score;
    string name;

    cout << "input student count:";
    cin >> num;
    Student *students = new Student[num];
    for (int i = 0; i < num; i++)
    {
        cout << "input student id and name:";
        cin >> id >> name;
        students[i] = Student(id, name);

        cout << "input Chinese, Maths and English score:";
        cin >> chinese_score >> maths_score >> english_score;
        students[i].setScore(chinese_score, maths_score, english_score);
    }

    cout << header_line << endl;
    for (int i = 0; i < num; i++)
    {
        students[i].render();
    }
}